import javax.swing.*;
import javax.swing.JTabbedPane;
import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JPopupMenu;

public class Project
{
	public static String role_session="";
	public static String root_session="";


	public static void main(String[] args)
	{
		final JFrame main_frame=new JFrame("Hackberry Framework");
		JDesktopPane desktop =new JDesktopPane();
		final JMenuBar menu=new JMenuBar();
		main_frame.setJMenuBar(menu);
		JMenu submenu=new JMenu("Root");
			JMenuItem Admin1=new JMenuItem("Injection");
			JMenuItem Admin2=new JMenuItem("View Log");
			JMenuItem Admin3=new JMenuItem("MasterCode");
		JMenu submenu2=new JMenu("Engineering");
			JMenuItem Engineering1=new JMenuItem("MasterRaw");
			JMenuItem Engineering2=new JMenuItem("FinishedGoods");
 		menu.add(submenu);
			submenu.add(Admin1);
			submenu.add(Admin3);
			submenu.add(Admin4);
			submenu.add(Admin5);
			submenu.addSeparator();
			submenu.add(Admin2);
		menu.add(submenu2);
			submenu2.add(Engineering1);
			submenu2.add(Engineering2);
			submenu2.add(Engineering3);

      //===  form login  ===
			final JInternalFrame frame_login=new JInternalFrame("Form Login",false,true,false,true);
			JLabel lblUsername=new JLabel("Username: ");
			final JTextField txtUsername=new JTextField(30);
			JLabel lblPassword=new JLabel("Password: ");
			final JPasswordField txtPassword=new JPasswordField(30);
			JButton btnLogin=new JButton("Login");

			Container content;
			konten=frame_login.getContentPane();
			konten.setLayout(null);
			konten.add(lblUsername);konten.add(txtUsername);
			konten.add(lblPassword);konten.add(txtPassword);
			konten.add(btnLogin);
			lblUsername.setBounds(0,0,100,20);
			txtUsername.setBounds(100,0,100,20);
			lblPassword.setBounds(0,20,100,20);
			txtPassword.setBounds(100,20,100,20);
			btnLogin.setBounds(0,40,100,20);

			frame_login.setSize(200,100);
			frame_login.setVisible(true);

			Admin1.addActionListener(new ActionListener()
			{
				public void actionPerformed(ActionEvent e)
				{
					if(sesi_hak_akses.equals("admin"))
					{
						frame_input_data_user.setVisible(true);
					}
					else
					{
						JOptionPane.showMessageDialog(main_frame,"Not Allowed","Error",JOptionPane.WARNING_MESSAGE);
					}
				}
			});
			Admin2.addActionListener(new ActionListener()
			{
				public void actionPerformed(ActionEvent e)
				{
					if(sesi_hak_akses.equals("admin"))
					{
						frame_view_log.setVisible(true);
					}
					else
					{
						JOptionPane.showMessageDialog(main_frame,"Not Allowed","Error",JOptionPane.WARNING_MESSAGE);
					}
				}
			});
			Admin3.addActionListener(new ActionListener()
			{
				public void actionPerformed(ActionEvent e)
				{
					if(sesi_hak_akses.equals("admin"))
					{
						frame_input_data_supplier.setVisible(true);
					}
					else
					{
						JOptionPane.showMessageDialog(main_frame,"Not Allowed","Error",JOptionPane.WARNING_MESSAGE);
					}
				}
			});
			Admin4.addActionListener(new ActionListener()
			{
				public void actionPerformed(ActionEvent e)
				{
					if(sesi_hak_akses.equals("admin"))
					{
						frame_input_data_customer.setVisible(true);
					}
					else
					{
						JOptionPane.showMessageDialog(main_frame,"Not Allowed","Error",JOptionPane.WARNING_MESSAGE);
					}
				}
			});
			Admin5.addActionListener(new ActionListener()
			{
				public void actionPerformed(ActionEvent e)
				{
					if(sesi_hak_akses.equals("admin"))
					{
					}
					else
					{
						JOptionPane.showMessageDialog(main_frame,"Not Allowed","Error",JOptionPane.WARNING_MESSAGE);
					}
				}
			});
			Engineering1.addActionListener(new ActionListener()
			{
				public void actionPerformed(ActionEvent e)
				{
					if(sesi_hak_akses.equals("engineering"))
					{
						frame_input_data_material.setVisible(true);
					}
					else
					{
						JOptionPane.showMessageDialog(main_frame,"Not Allowed","Error",JOptionPane.WARNING_MESSAGE);
					}
				}
			});
			Engineering2.addActionListener(new ActionListener()
			{
				public void actionPerformed(ActionEvent e)
				{
					if(sesi_hak_akses.equals("engineering"))
					{
						frame_input_data_fg.setVisible(true);
					}
					else
					{
						JOptionPane.showMessageDialog(main_frame,"Not Allowed","Error",JOptionPane.WARNING_MESSAGE);
					}

				}
			});
			Engineering3.addActionListener(new ActionListener()
			{
				public void actionPerformed(ActionEvent e)
				{
					if(sesi_hak_akses.equals("engineering"))
					{
						frame_input_data_bom.setVisible(true);
					}
					else
					{
						JOptionPane.showMessageDialog(main_frame,"Not Allowed","Error",JOptionPane.WARNING_MESSAGE);
					}
				}
			});
         
		return 0;
	}
}